package com.sky.directdeal.adapter;

import java.util.List;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.sky.directdeal.R;
import com.sky.local_ads.offer_cat_list.OffersCategoryList;

public class NavDrawerListAdapter extends BaseAdapter {
	
	private Context context;
	private List<OffersCategoryList> navDrawerItems;
	
	public NavDrawerListAdapter(Context context, List<OffersCategoryList> categoryLists){
		this.context = context;
		this.navDrawerItems = categoryLists;
	}

	@Override
	public int getCount() {
		return navDrawerItems.size();
	}

	@Override
	public Object getItem(int position) {		
		return navDrawerItems.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		if (convertView == null) {
            LayoutInflater mInflater = (LayoutInflater)
                    context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
            convertView = mInflater.inflate(R.layout.drawer_list_item, null);
        }
         
        TextView txtTitle = (TextView) convertView.findViewById(R.id.title);
        TextView txtCount = (TextView) convertView.findViewById(R.id.counter);
         
        txtTitle.setText(navDrawerItems.get(position).getCatTitle());
        
        // displaying count
        // check whether it set visible or not
        int count=navDrawerItems.get(position).getCount();
        if(count>0){
        	txtCount.setText(navDrawerItems.get(position).getCount()+"");
        }else{
        	// hide the counter view
        	txtCount.setVisibility(View.GONE);
        }
        
        return convertView;
	}

}
